{
GtkEventController parent_instance;
- GdkEvent *current_event;
- const GtkCrossingData *current_crossing;
-
guint is_pointer : 1;
guint contains_pointer : 1;
};
if (crossing->direction == GTK_CROSSING_IN)
{
+ if (crossing->new_descendent != NULL)
+ {
+ contains_pointer = TRUE;
+ }
if (crossing->new_target == widget)
- is_pointer = TRUE;
- if (crossing->new_target != NULL)
+ {
+ contains_pointer = TRUE;
+ is_pointer = TRUE;
+ }
+ }
+ else
+ {
+ if (crossing->new_descendent != NULL ||
+ crossing->new_target == widget)
contains_pointer = TRUE;
+ is_pointer = FALSE;
}
if (motion->contains_pointer != contains_pointer)
{
- if (contains_pointer)
- enter = TRUE;
- else
- leave = TRUE;
+ enter = contains_pointer;
+ leave = !contains_pointer;
}
if (leave)
double x,
double y)
{
- GtkEventControllerMotion *motion = GTK_EVENT_CONTROLLER_MOTION (controller);
-
- if (crossing->type != GTK_CROSSING_POINTER)
- return;
-
- motion->current_crossing = crossing;
-
- update_pointer_focus (controller, crossing, x, y);
-
- motion->current_crossing = NULL;
+ if (crossing->type == GTK_CROSSING_POINTER)
+ update_pointer_focus (controller, crossing, x, y);
}
static void
GdkCrossingMode mode)
{
GtkCrossingData crossing;
+ GtkWidget *ancestor;
GtkWidget *widget;
GList *list, *l;
double x, y;
+ GtkWidget *prev;
+ gboolean seen_ancestor;
+
+ if (old_target && new_target)
+ ancestor = gtk_widget_common_ancestor (old_target, new_target);
+ else
+ ancestor = NULL;
crossing.type = GTK_CROSSING_POINTER;
crossing.mode = mode;
crossing.old_target = old_target;
+ crossing.old_descendent = NULL;
crossing.new_target = new_target;
+ crossing.new_descendent = NULL;
crossing.direction = GTK_CROSSING_OUT;
+ prev = NULL;
+ seen_ancestor = FALSE;
widget = old_target;
while (widget)
{
+ crossing.old_descendent = prev;
+ if (seen_ancestor)
+ {
+ crossing.new_descendent = new_target ? prev : NULL;
+ }
+ else if (widget == ancestor)
+ {
+ GtkWidget *w;
+
+ crossing.new_descendent = NULL;
+ for (w = new_target; w != ancestor; w = gtk_widget_get_parent (w))
+ crossing.new_descendent = w;
+
+ seen_ancestor = TRUE;
+ }
+ else
+ {
+ crossing.new_descendent = NULL;
+ }
+ check_crossing_invariants (widget, &crossing);
translate_event_coordinates (event, &x, &y, widget);
gtk_widget_handle_crossing (widget, &crossing, x, y);
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
}
list = NULL;
- widget = new_target;
- while (widget)
- {
- list = g_list_prepend (list, widget);
- widget = gtk_widget_get_parent (widget);
- }
+ for (widget = new_target; widget; widget = gtk_widget_get_parent (widget))
+ list = g_list_prepend (list, widget);
crossing.direction = GTK_CROSSING_IN;
+ seen_ancestor = FALSE;
for (l = list; l; l = l->next)
{
widget = l->data;
+ if (l->next)
+ crossing.new_descendent = l->next->data;
+ else
+ crossing.new_descendent = NULL;
+ if (seen_ancestor)
+ {
+ crossing.old_descendent = NULL;
+ }
+ else if (widget == ancestor)
+ {
+ GtkWidget *w;
+
+ crossing.old_descendent = NULL;
+ for (w = old_target; w != ancestor; w = gtk_widget_get_parent (w))
+ crossing.old_descendent = w;
+
+ seen_ancestor = TRUE;
+ }
+ else
+ {
+ crossing.old_descendent = old_target ? crossing.new_descendent : NULL;
+ }
+
translate_event_coordinates (event, &x, &y, widget);
gtk_widget_handle_crossing (widget, &crossing, x, y);
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
#include "gtkcsstypesprivate.h"
#include "gtktexthandleprivate.h"
+#include "gtkeventcontrollerprivate.h"
G_BEGIN_DECLS
GdkEvent *event);
void gtk_main_do_event (GdkEvent *event);
+GtkWidget *gtk_get_event_widget (GdkEvent *event);
+
+void check_crossing_invariants (GtkWidget *widget,
+ GtkCrossingData *crossing);
+
gdouble _gtk_get_slowdown (void);
void _gtk_set_slowdown (gdouble slowdown_factor);
gtk_window_set_focus (GTK_WINDOW (widget), NULL);
}
-static void
+void
check_crossing_invariants (GtkWidget *widget,
GtkCrossingData *crossing)
{
+#ifdef G_ENBABLE_DEBUG
if (crossing->old_target == NULL)
g_assert (crossing->old_descendent == NULL);
else if (crossing->old_descendent == NULL)
g_assert (gtk_widget_is_ancestor (crossing->new_descendent, widget));
g_assert (crossing->new_target == crossing->new_descendent || gtk_widget_is_ancestor (crossing->new_target, crossing->new_descendent));
}
+#endif
}
static void